<template>
<div class="app-container">
  <loading v-show="loading"></loading>
  <el-card class="box-card searchFormStyle" style="margin-bottom:1%;">
    <div slot="header" class="clearfix">
      <span>党组织机构管理</span>
    </div>
    <div class="text item">
      <el-form ref="SearchDep" :model="SearchDep" label-width="130px">
        <el-row>
          <el-col :span="8">
            <el-form-item label="机构编码">
              <el-input v-model="SearchDep.partyOrgCode"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构名称">
              <el-input v-model="SearchDep.partyOrgName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="父级机构">
              <el-popover
                placement="bottom"
                width="400"
                height="300px"
                trigger="click">
                <el-tree
                  :data="partorgData"
                  :props="defaultProps"
                  accordion
                  @node-click="handleNodeClick"
                  >
                </el-tree>
                <el-input v-model="searchparentOrgName"  slot="reference" readonly></el-input>
              </el-popover>
              <el-input type="hidden" v-model="SearchDep.parPartyOrgInfoKey" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col>
            <el-form-item>
              <el-button type="primary" 
              icon="el-icon-plus" 
              v-if="permissionHandle('party:openDialog')"
              @click="openDialog">新 增</el-button>
              <el-button type="primary" 
              icon="el-icon-search" 
              v-if="permissionHandle('party:getList')"
              @click="getList">查 询</el-button>
              <el-button type="primary" 
              icon="el-icon-refresh" 
              v-if="permissionHandle('party:getList')"
              @click="resetSearch">重 置</el-button>
              <el-button type="info" 
              icon="el-icon-delete" 
              v-if="permissionHandle('party:handleDelete')"
              @click="deleteDepar">删 除</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </el-card>
  <el-card class="box-card" style="margin-bottom:1%;">
    <div slot="header" class="clearfix">
      <span>党组织机构列表</span>
    </div>
    <el-table
      :data="tableData"
      ref="tableData"
      border
      style="width: 100%;margin-bottom:1%;"
      @selection-change="handleSelectionChange"
      >
      <el-table-column
        type="selection"
        width="40">
      </el-table-column>
      <el-table-column
        label="机构编码"
        width="180">
        <template slot-scope="scope">
            {{ scope.row.partyOrgCode }}
        </template>
      </el-table-column>
      <el-table-column
        label="机构名称"
      >
        <template slot-scope="scope">
            {{ scope.row.partyOrgName }}
        </template>
      </el-table-column>
      <el-table-column
        label="父级机构"
      >
        <template slot-scope="scope">
            {{ scope.row.parPartyOrgInfoKey }}
        </template>
      </el-table-column>
      <el-table-column
        label="创建日期"
        width="180"
        prop="createTime"
      >
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="300px">
        <template slot-scope="scope">
          <el-button
            size="mini"
            icon="el-icon-document"
            v-if="permissionHandle('party:handleDetails')"
            @click="handleLook(scope.$index, scope.row)">详细</el-button>
          <el-button
            size="mini"
            icon="el-icon-edit-outline"
            v-if="permissionHandle('party:handleEdit')"
            @click="handleEdit(scope.$index, scope.row)">修改</el-button>
          <el-button
            size="mini"
            icon="el-icon-delete"
            type="danger"
            v-if="permissionHandle('party:handleDelete')"
            @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination @handleCurrentChange="handleCurrentChange" @handleSizeChange="handleSizeChange" :paginations="paginations"></pagination>
  </el-card>
  <!--新增角色-->
  <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" width="80%">
    <el-form :model="addForm" :rules="rules" ref="addForm" label-width="120px">
      <el-row>
          <el-col :span="8">
            <el-form-item label="机构编码" prop="partyOrgCode">
              <el-input v-model="addForm.partyOrgCode" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构名称" prop="partyOrgName">
              <el-input v-model="addForm.partyOrgName" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构类型" prop="partyOrgType">
              <el-select v-model="addForm.partyOrgType" placeholder="请选择机构类型" style="width:100%;">
                <el-option v-for="item in options" :label="item.paramName" :value="item.paramValue" :key="item.paramKey"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row>
          <el-col :span="8">
            <el-form-item label="机构书记" prop="partyOrgSecretary">
              <el-input v-model="addForm.partyOrgSecretary" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构联系人" prop="partyOrgLinkman">
              <el-input v-model="addForm.partyOrgLinkman" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系人电话" prop="partyOrgLinkmanPhone">
              <el-input v-model="addForm.partyOrgLinkmanPhone" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row>
          <el-col :span="8">
            <el-form-item label="单位情况" prop="unitSituation">
              <el-input v-model="addForm.unitSituation" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="建立党组织情况" prop="partySituation">
              <el-input v-model="addForm.partySituation" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构排序" prop="partyOrgNumber">
              <el-input v-model="addForm.partyOrgNumber" auto-complete="off"></el-input>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row>
         <el-col :span="8">
           <el-form-item label="所属党组织机构" class="tree-input">
             <el-popover
                placement="bottom"
                width="400"
                trigger="click">
                <el-tree
                  :data="partorgData"
                  show-checkbox
                  :props="defaultProps"
                  check-strictly
                  ref="parOrgTree"
                  node-key="partyOrgKey"
                  :default-checked-keys="[addForm.parPartyOrgInfoKey]"
                  accordion
                  @check="handleClick"
                  >
                </el-tree>
                <el-input v-model="parentOrgName"  slot="reference" readonly></el-input>
              </el-popover>
              <el-input type="hidden" v-model="addForm.parPartyOrgInfoKey" auto-complete="off"></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="所属行政机构" class="tree-input">
             <el-popover
                placement="bottom"
                width="400"
                trigger="click">
                <el-tree
                  :data="orgData"
                  show-checkbox
                  :props="orgProps"
                  check-strictly
                  ref="orgTree"
                  node-key="orgKey"
                  :default-checked-keys="[addForm.orgKey]"
                  accordion
                  @check="handleOrgClick"
                  >
                </el-tree>
                <el-input v-model="orgName"  slot="reference" readonly></el-input>
              </el-popover>
              <el-input type="hidden" v-model="addForm.orgKey" auto-complete="off"></el-input>
           </el-form-item>
         </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button icon="el-icon-refresh" @click="resetForm('addForm')">重置</el-button>
      <el-button icon="el-icon-plus" type="primary" @click="submitForm('addForm')">确 定</el-button>
    </div>
  </el-dialog>
  <!--详细-->
  <el-dialog :title="dialogTitle" :visible.sync="detailFormVisible" width="80%">
    <el-form :model="addForm" :rules="rules" ref="addForm"  :disabled="ifDisabled" label-width="120px"  class="detailStyle">
      <el-row>
          <el-col :span="8">
            <span class="labelSpan">
                机构编码:
            </span>
            <span class="valueSpan">
              {{addForm.partyOrgCode}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                机构名称:
            </span>
            <span class="valueSpan">
              {{addForm.partyOrgName}}
            </span>
          </el-col>
          <el-col :span="8">
            <el-form-item label="机构类型" prop="partyOrgType">
              <el-select v-model="addForm.partyOrgType" placeholder="请选择机构类型" style="width:100%;">
                <el-option v-for="item in options" :label="item.paramName" :value="item.paramValue" :key="item.paramKey"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row>
          <el-col :span="8">
            <span class="labelSpan">
                机构书记:
            </span>
            <span class="valueSpan">
              {{addForm.partyOrgSecretary}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                机构联系人:
            </span>
            <span class="valueSpan">
              {{addForm.partyOrgLinkman}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                联系人电话:
            </span>
            <span class="valueSpan">
              {{addForm.partyOrgLinkmanPhone}}
            </span>
          </el-col>
      </el-row>
      <el-row>
          <el-col :span="8">
            <span class="labelSpan">
                单位情况:
            </span>
            <span class="valueSpan">
              {{addForm.unitSituation}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                建立党组织情况:
            </span>
            <span class="valueSpan">
              {{addForm.partySituation}}
            </span>
          </el-col>
          <el-col :span="8">
            <span class="labelSpan">
                机构排序:
            </span>
            <span class="valueSpan">
              {{addForm.partyOrgNumber}}
            </span>
          </el-col>
      </el-row>
      <el-row>
         <el-col :span="8">
           <el-form-item label="所属党组织机构:" class="tree-input">
             <el-input type="hidden" v-model="addForm.parPartyOrgInfoKey" auto-complete="off" style="height:0;display:inline;"></el-input>
             <el-popover
                placement="bottom"
                width="400"
                disabled
                trigger="click">
                <el-tree
                  :data="partorgData"
                  show-checkbox
                  :props="defaultProps"
                  check-strictly
                  ref="parOrgTree"
                  node-key="partyOrgKey"
                  :default-checked-keys="[addForm.parPartyOrgInfoKey]"
                  accordion
                  @check="handleClick"
                  >
                </el-tree>
                <el-input v-model="parentOrgName"  slot="reference" readonly></el-input>
              </el-popover>

           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="所属行政机构:" class="tree-input">
             <el-popover
                placement="bottom"
                width="400"
                disabled
                trigger="click">
                <el-tree
                  :data="orgData"
                  show-checkbox
                  :props="orgProps"
                  check-strictly
                  ref="orgTree"
                  node-key="orgKey"
                  :default-checked-keys="[addForm.orgKey]"
                  accordion
                  @check="handleOrgClick"
                  >
                </el-tree>
                <el-input v-model="orgName"  slot="reference" readonly></el-input>
              </el-popover>
              <el-input type="hidden" v-model="addForm.orgKey" auto-complete="off"></el-input>
           </el-form-item>
         </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</div>
</template>
<script>
import Loading from '@/components/loading/loading'
import pagination from '@/components/pagination/index'
import { getAllDepartment, getDepartmentList, addDepartment, deleteDepartment, changeDepartment } from '@/api/party/party'
import { transform } from '@/utils/trans'
import { isvalidPhone, isvalidNumber, isvalidRequire } from '@/utils/validate'
// 非空
var validateRequire = (rule, value, callback) => {
  if (!isvalidRequire(value)) {
    callback(new Error('请输入必填项'))
  } else {
    callback()
  }
}
// 数字验证
var validNumber = (rule, value, callback) => {
  if (!isvalidNumber(value)) {
    callback(new Error('只能输入大于0的数字'))
  } else {
    callback()
  }
}
// 手机号
var validPhone = (rule, value, callback) => {
  if (!value) {
    callback(new Error('请输入电话号码'))
  } else if (!isvalidPhone(value)) {
    callback(new Error('请输入正确的11位手机号码'))
  } else {
    callback()
  }
}
export default {
  components: {
    Loading,
    pagination
  },
  data() {
    this.permissionHandle = this.$permissionHandle
    return {
      dialogTitle: '',
      loading: false,
      SearchDep: {
        partyOrgName: '',
        partyOrgCode: '',
        parPartyOrgInfoKey: '',
        pageSize: '10',
        pageNum: '1'
      },
      paginations: {
        totalNum: 0,
        currentPage: 1,
        pageSize: 10
      },
      deleteDep: {
        partyOrgKey: ''
      },
      // 禁用表单
      ifDisabled: false,
      deleteDepArry: [],
      options: [],
      allDepartmentData: [],
      tableData: [],
      // 新增角色数据
      addForm: {
        partyOrgCode: '',
        parPartyOrgInfoKey: '',
        partyOrgName: '',
        partyOrgType: '',
        partyOrgSecretary: '',
        partyOrgLinkman: '',
        partyOrgLinkmanPhone: '',
        partyOrgKey: '',
        unitSituation: '',
        partySituation: '',
        partyOrgNumber: '',
        orgKey: ''
      },
      parentOrgName: '',
      searchparentOrgName: '',
      orgName: '',
      dialogFormVisible: false, // 新增弹出框状态
      detailFormVisible: false,
      // 列表所选数据集合
      multipleSelection: [],
      rules: {
        partyOrgCode: [
          { required: true, message: '请输入机构编码' },
          { min: 1, max: 32, message: '长度在 1 到 32 个字符', trigger: 'blur' },
          { trigger: 'blur', validator: validNumber }
        ],
        partyOrgNumber: [
          { type: 'number', validator: validNumber }
        ],
        partyOrgName: [
          { required: true, message: '请输入机构名称' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 30, message: '长度在 1 到 30 个字符', trigger: 'blur' }
        ],
        partyOrgType: [
          { required: true, message: '请选择机构类型' }
        ],
        partyOrgSecretary: [
          { required: true, message: '请输入党组织机构书记' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 5, message: '长度在 1 到 5 个字符', trigger: 'blur' }
        ],
        partyOrgLinkman: [
          { required: true, message: '请输入党组织机构联系人' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 5, message: '长度在 1 到 5 个字符', trigger: 'blur' }
        ],
        partyOrgLinkmanPhone: [
          { message: '联系电话格式错误', trigger: 'blur', validator: validPhone }
        ],
        unitSituation: [
          { required: true, message: '请输入党组织所在单位情况' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 300, message: '长度在 1 到 300个字符', trigger: 'blur' }
        ],
        partySituation: [
          { required: true, message: '请输入单位建立党组织情况' },
          { message: '数据不能包含特殊字符', validator: validateRequire },
          { min: 1, max: 300, message: '长度在 1 到 300个字符', trigger: 'blur' }
        ]
      },
      // 组织机构
      orgData: [],
      partorgData: [],
      defaultProps: {
        value: 'partyOrgKey',
        parentId: 'parPartyOrgInfoKey',
        children: 'children',
        label: 'partyOrgName'
      },
      orgProps: {
        value: 'orgKey',
        parentId: 'parOrg',
        children: 'children',
        label: 'orgName'
      }
    }
  },
  watch: {
    dialogFormVisible: function() {
      if (this.dialogFormVisible === false) {
        this.addForm = {
          partyOrgCode: '',
          parPartyOrgInfoKey: '',
          partyOrgName: '',
          partyOrgType: '',
          partyOrgSecretary: '',
          partyOrgLinkman: '',
          partyOrgLinkmanPhone: '',
          partyOrgKey: '',
          unitSituation: '',
          partySituation: '',
          partyOrgNumber: ''
        }
        this.parentOrgName = ''
        this.orgName = ''
        this.resetForm('addForm')
        this.ifDisabled = false
      }
    }
  },
  created() {
    this.getAll()
    this.getPartyList()
  },
  updated() {
  },
  methods: {
    getNodes() {
      if (this.dialogFormVisible || this.detailFormVisible) {
        console.log(this.addForm)
        console.log(this.$refs.orgTree.getNode(this.addForm.orgKey))
        if (this.$refs.orgTree && this.addForm.orgKey) {
          if (!this.$refs.orgTree.getNode(this.addForm.orgKey)) {
            return false
          } else {
            // 默认选中组织机构
            this.orgName = this.$refs.orgTree.getNode(this.addForm.orgKey).data.orgName
            this.addForm.orgKey = this.$refs.orgTree.getNode(this.addForm.orgKey).data.orgKey
          }
        } else {
          this.orgName = ''
          this.addForm.orgKey = '-1'
        }
        if (this.$refs.parOrgTree && this.addForm.parPartyOrgInfoKey) {
        // 默认选中组织机构
          if (!this.$refs.parOrgTree.getNode(this.addForm.parPartyOrgInfoKey)) {
            return false
          } else {
            this.parentOrgName = this.$refs.parOrgTree.getNode(this.addForm.parPartyOrgInfoKey).data.partyOrgName
            this.addForm.parPartyOrgInfoKey = this.$refs.parOrgTree.getNode(this.addForm.parPartyOrgInfoKey).data.partyOrgKey
          }
        } else {
          this.parentOrgName = ''
          this.addForm.parPartyOrgInfoKey = ''
        }
      }
    },
    // 修改时选择父级机构
    handleClick(data, checked, node) {
      if (data.partyOrgKey !== this.addForm.partyOrgKey) {
        this.parentOrgName = data.partyOrgName
        this.addForm.parPartyOrgInfoKey = data.partyOrgKey
        if (checked) {
          this.$refs.parOrgTree.setCheckedNodes([])
          this.$refs.parOrgTree.setCheckedNodes([data])
        // 交叉点击节点
        } else {
          this.$refs.parOrgTree.setCheckedNodes([])
        // 点击已经选中的节点，置空
        }
      } else {
        this.$message({
          showClose: true,
          message: '不能选择自身作为父级机构',
          type: 'warning'
        })
        this.$refs.parOrgTree.setCheckedNodes([])
      }
    },
    handleOrgClick(data, checked, node) {
      this.orgName = data.orgName
      this.addForm.orgKey = data.orgKey
      if (checked) {
        this.$refs.orgTree.setCheckedNodes([])
        this.$refs.orgTree.setCheckedNodes([data])
        // 交叉点击节点
      } else {
        this.$refs.orgTree.setCheckedNodes([])
        // 点击已经选中的节点，置空
      }
    },
    // 新增打开弹出框
    openDialog() {
      this.dialogFormVisible = true
      this.dialogTitle = '党组织机构新增'
      this.addForm = {
        partyOrgKey: ''
      }
      this.changeDep('add')
    },
    handleEdit(index, row) {
      this.addForm = {
        partyOrgKey: row.partyOrgKey
      }
      this.changeDep('edit')
      this.dialogFormVisible = true
      this.dialogTitle = '党组织机构修改'
    },
    // 修改
    changeDep(parmater) {
      return new Promise((resolve, reject) => {
        changeDepartment(this.addForm).then(response => {
          this.options = response.data.PARTYORGTYPE
          if (parmater === 'edit') {
            this.addForm = response.data.entity
          }
          if (parmater === 'detail') {
            this.ifDisabled = true
            this.addForm = response.data.entity
          }
          this.orgData = transform(response.data.org, 'orgKey', 'parOrg', 'children')
          this.partorgData = transform(response.data.tree, 'partyOrgKey', 'parPartyOrgInfoKey', 'children')
          this.getNodes()
          // this.orgData = transform(this.allDepartmentData, 'orgKey', 'parOrg', 'children')
          // console.log(this.orgData)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 获取全部部门机构数据
    getAll() {
      return new Promise((resolve, reject) => {
        getAllDepartment().then(response => {
          this.allDepartmentData = response.data
          // console.log(this.allDepartmentData)
          this.partorgData = transform(response.data, 'partyOrgKey', 'parPartyOrgInfoKey', 'children')
          // console.log(this.orgData)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    getList() {
      this.getPartyList()
    },
    blurSearch() {
      this.SearchDep.pageNum = 1
      this.getList()
      this.paginations.currentPage = 1
    },
    getPartyList() {
      this.loading = true
      return new Promise((resolve, reject) => {
        getDepartmentList(this.SearchDep).then(response => {
          // console.log(this.SearchDep)
          this.tableData = response.data.items
          this.paginations.totalNum = parseInt(response.data.itemsTotalCount)
          resolve()
          this.loading = false
        }).catch(error => {
          this.loading = false
          reject(error)
        })
      })
    },
    // 新增
    addDepar() {
      this.loading = true
      if (!this.addForm.parPartyOrgInfoKey) {
        this.addForm.parPartyOrgInfoKey = '-1'
      }
      this.addForm.partyOrgNumber = parseInt(this.addForm.partyOrgNumber)
      return new Promise((resolve, reject) => {
        addDepartment(this.addForm).then(response => {
          resolve()
          this.dialogFormVisible = false
          this.getAll()
          this.getList()
          this.loading = false
        }).catch(error => {
          this.loading = false
          reject(error)
        })
      })
    },
    // 删除
    deleteDepar() {
      if (this.deleteDepArry.length) {
        this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          return new Promise((resolve, reject) => {
            deleteDepartment({ 'partyOrgKey': JSON.stringify(this.deleteDepArry) }).then(response => {
              resolve()
              this.loading = false
              this.getAll()
              this.getList()
              this.deleteDepArry = []
            }).catch(error => {
              this.loading = false
              this.deleteDepArry = []
              reject(error)
            })
          })
        }).catch(() => {
          this.deleteDepArry = []
          this.$refs.tableData.clearSelection()
          return
        })
      } else {
        this.$message({
          showClose: true,
          message: '请至少选择一条要删除的数据',
          type: 'warning'
        })
      }
    },
    handleDelete(index, row) {
      this.$refs.tableData.clearSelection()
      this.deleteDepArry = []
      this.deleteDepArry.push(row.partyOrgKey)
      this.deleteDepar()
    },
    handleSelectionChange(val) {
      this.deleteDepArry = []
      this.multipleSelection = val
      this.multipleSelection.forEach(element => {
        this.deleteDepArry.push(element.partyOrgKey)
      })
    },
    // 改变分页的时候查询数据
    handleSizeChange(val) {
      this.SearchDep.pageSize = val
      this.getPartyList()
    },
    handleCurrentChange(val) {
      this.SearchDep.pageNum = val
      this.getPartyList()
    },

    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.addDepar()
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
    resetForm(formName) {
      if (this.addForm.partyOrgKey) {
        this.changeDep('edit')
      } else {
        this.addForm = {
          partyOrgCode: '',
          parPartyOrgInfoKey: '',
          partyOrgName: '',
          partyOrgType: '',
          partyOrgSecretary: '',
          partyOrgLinkman: '',
          partyOrgLinkmanPhone: '',
          partyOrgKey: '',
          unitSituation: '',
          partySituation: '',
          partyOrgNumber: ''
        }
        this.parentOrgName = ''
        this.orgName = ''
        this.ifDisabled = false
        this.$refs.orgTree.setCheckedKeys([])
        this.$refs.parOrgTree.setCheckedKeys([])
        this.$refs[formName].resetFields()
      }
    },
    handleNodeClick(data) {
      this.searchparentOrgName = data.partyOrgName
      this.SearchDep.parPartyOrgInfoKey = data.partyOrgKey
    },
    handleLook(index, row) {
      this.addForm = {
        partyOrgKey: row.partyOrgKey
      }
      this.ifDisabled = true
      this.changeDep('detail')
      this.detailFormVisible = true
      this.dialogTitle = '党组织机构详细'
    },
    resetSearch() {
      this.SearchDep.partyOrgName = ''
      this.SearchDep.partyOrgCode = ''
      this.SearchDep.parPartyOrgInfoKey = ''
      this.searchparentOrgName = ''
      this.getAll()
      this.getPartyList()
    }
  }
}
</script>
<style lang="scss" scoped>
  .tree-input{
    position: relative;
  }
  .input-tree{
      height:200px;width: 100%;
      .el-scrollbar__wrap{overflow: auto;}
    }
    .tree-select{width: 100%;}
</style>
